package com.k2.gulimall.member.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

import static com.k2.common.constant.AuthServerConstant.LOGIN_USER;

@Controller
@RequestMapping("member/memberlogin")
public class MemberLoginController {

    @GetMapping(value = "/member.html")
    public String loginPage(HttpSession session) {
        //从session先取出来用户的信息，判断用户是否已经登录过了
        Object attribute = session.getAttribute(LOGIN_USER);
        //如果用户没登录那就跳转到登录页面
        System.out.println(attribute);
        if (attribute == null) {
            return "redirect:http://localhost:20000/login.html";
        } else {
            return "member";
        }
    }




}
